package routers

import (
	"NovelBook/controller/worker"
	"NovelBook/utils/auth"

	"github.com/gin-gonic/gin"
)

func SetWorkerRouter(r *gin.Engine) {

	// worker 注册由管理员进行
	// r.POST(baseUrl+workerUrl+"/register", worker.Register)

	// worker 登录

	r.POST(baseUrl+workerUrl+"/login-account", worker.LoginByAccount)

	r.POST(baseUrl+workerUrl+"/login-email", worker.LoginByEmail)

	r.POST(baseUrl+workerUrl+"/reset-password", worker.ResetPassword)

	wkr := r.Group(baseUrl + workerUrl)
	wkr.Use(auth.JWTAuthSuperUser(), auth.JWTAuthWorker())
	{
		//以下api规则可按照需求进行修改

		// 修改昵称或者头像
		wkr.PUT("/user", worker.Modify)

		// 获取所有书籍信息
		wkr.GET("/books/info-all", worker.GetAllBooks)

		// 根据 book ID 获取书籍信息
		wkr.GET("/books/info-id")

		// 创建书籍
		wkr.POST("/books/new", worker.CreateBooks)

		// 根据 book ID 删除书籍
		wkr.DELETE("/books/del-id", worker.DelBooks)

		// 根据 book ID 更新书籍信息
		wkr.PUT("/books/update-id", worker.UpdateBooks)

		// 获取用户借书情况
		wkr.GET("/books/borrowed/borrower-id")

		// 获取书籍被借阅情况
		wkr.GET("/books/borrowed/book-id", worker.GetBorrowedInfoByBookID)

		// 归还用户借阅的书籍
		wkr.POST("/books/return/book", worker.ReturnBorrowerBooks)

		// worker 处的借书
		wkr.POST("/books/borrow", worker.BorrowBooks)
		// any other API you need
	}

	// any other worker API you need
}
